# -*- coding: utf-8 -*-

'''
Class StartServerHTTP - Start index.html in browser
Classe StartServerHTTP - Inicia o index.html no browser
@author - David Guerreiro - Nº4903
data: 17- JUL -2011
'''

import SimpleHTTPServer
import SocketServer
import threading
import webbrowser

class StartServerHTTP:

    ## Start server in port 8000 | use different thread of aplication 
    ## inicia o servidor na porta 8000 | usa um thread diferente da aplicação
    def __init__(self):
        
        try:
            self.porta = 8000
            self.handler = SimpleHTTPServer.SimpleHTTPRequestHandler   
            self.httpd = SocketServer.TCPServer(("", self.porta), self.handler)  
            self.server_thread = threading.Thread(target=self.httpd.serve_forever)
            self.server_thread.setDaemon(True)
            self.server_thread.start()  

        except:
            print "ERRO NA LIGACAO AO SERVIDOR"

        webbrowser.open("http://localhost:8000/HTML/index.html".encode('utf-8'))
    pass
      
pass
